package cn.sowz.log.aspectj;

import cn.sowz.log.annotation.Log;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
@Slf4j
public class LogAspect {
    @Pointcut("@annotation(logg)")
    public void webLog(Log logg){}

    @Before("webLog(logg)")
    public void doBefore(JoinPoint joinPoint,Log logg){
        log.info("打印请求日志before: {}",logg);
    }

    @AfterReturning(returning = "ret", pointcut = "webLog(logg)")
    public void doAfterReturning(Object ret,Log logg){
        // 打印响应结果日志
        log.info("打印响应结果日志doAfterReturning: {}",logg);
    }
}
